package com.ruoyi.web.controller.warning;

import com.ruoyi.common.core.domain.R;
import com.ruoyi.warning.domain.entity.DrawingBoard;
import com.ruoyi.warning.domain.vo.DrawingBoardVO;
import com.ruoyi.warning.mapper.DrawingBoardMapper;
import com.ruoyi.warning.service.IDrawingBoardService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 画板表 前端控制器
 * </p>
 *
 * @author chenhc
 * @since 2025-04-27
 */
@RestController
@RequestMapping("/drawingBoard")
@Api(tags = "画板", description = "用于处理画板相关操作的控制器")
public class DrawingBoardController {
    @Resource
    private IDrawingBoardService drawingBoardService;
    @Resource
    private DrawingBoardMapper drawingBoardMapper;

    @ApiOperation("list")
    //@PreAuthorize("@ss.hasPermi('system:config:export')")
    @GetMapping(value = "/list")
    public R list()
    {
        List<DrawingBoardVO> list = drawingBoardMapper.list();
        return R.ok(list);
    }

    @ApiOperation("增加或修改")
    //@PreAuthorize("@ss.hasPermi('system:config:export')")
    @PostMapping(value = "/saveOrUpdate")
    public R saveOrUpdate(@RequestBody DrawingBoard drawingBoard){
        drawingBoardService.saveOrUpdate(drawingBoard);
        return R.ok();
    }

    @ApiOperation("删除")
    //@PreAuthorize("@ss.hasPermi('system:config:export')")
    @DeleteMapping(value = "/delete/{id}")
    public R delete(@PathVariable Long id){
        drawingBoardService.removeById(id);
        return R.ok();
    }

    @ApiOperation("新增或更新画板的云信息")
    @PostMapping(value = "/saveOrUpdateCloud")
    public R saveOrUpdateCloud(@RequestBody List<DrawingBoard> list)
    {
        return R.ok(drawingBoardService.saveOrUpdateBatch(list));
    }
}
